home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 526-550 / disk_542 / chemnimate / cmtsource.lzh / ConvDoc.c < prev    next >
C/C++ Source or Header  |  1991-08-28  |  1KB  |  69 lines

  1. /***********
  2.  * THIS PROGRAM IS WRITTEN TO CONVERT THE Language.DOC INTO A FILE WHICH
  3.  * DOESN'T CONTAIN ANY <CSI> (0x9B) CODES ANYMORE.
  4.  *
  5.  * TO COMPILE USING DICE 2.06.18R:
  6.  * DCC ConvDoc.c -oConvDoc -1.3 -r -v
  7.  *
  8.  *
  9.  * © Klaas  van Gend
  10.  *   Hoekerstraat 9b
  11.  *   5987 AN  EGCHEL
  12.  *   The Netherlands
  13.  *
  14.  */
  15.  
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18.  
  19. FILE *infile = NULL;
  20. FILE *outfile = NULL;
  21.  
  22.  
  23. main (int argc, char **argv)
  24. {
  25.   int dummy;
  26.  
  27.   if (argc != 3 || argv[1][0] == '?')
  28.     {
  29.       printf ("%s <infile> <outfile>\n", argv[0]);
  30.       printf ("To convert docs with 0x9b-codes to standard ASCII.\n");
  31.       Quit ();
  32.     }
  33.  
  34.  
  35.   if (!(infile = (FILE *) fopen (argv[1], "r")))
  36.     {
  37.       printf ("'%s' not found...\n", argv[1]);
  38.       Quit ();
  39.     }
  40.   if (!(outfile = (FILE *) fopen (argv[2], "w")))
  41.     {
  42.       printf ("Can't open output-file '%s'\n", argv[2]);
  43.       Quit ();
  44.     }
  45.   printf ("Files successfully opened\n");
  46.  
  47. /*** start checking***/
  48.   while ((dummy = fgetc (infile)) != EOF)
  49.     {
  50.       if (dummy == 0x9b)    /* BINGO */
  51.     {
  52.       while (fgetc (infile) != 'm') ;
  53.       continue;
  54.     }
  55.       fputc (dummy, outfile);
  56.     }
  57.   printf ("Finished...\n");
  58.   Quit ();
  59. }
  60.  
  61. Quit ()
  62. {
  63.   if (outfile)
  64.     fclose (outfile);
  65.   if (infile)
  66.     fclose (infile);
  67.   exit (0);
  68. }
  69.